package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.bean.UserDataBean;
import com.xuxin.baby.contract.UserRechargeContract;
import com.xuxin.baby.model.UserRechargeModel;

/**
 * Created by xu_xin
 * Created on 2020/10/23 0023
 * 充值
 */
public class UserRechargePresenter implements UserRechargeContract.Presenter {
    private final UserRechargeModel model;
    private final UserRechargeContract.View view;

    public UserRechargePresenter(UserRechargeContract.View view) {
        this.view = view;
        model = new UserRechargeModel();
    }

    @Override
    public void recharge(String tenantId, String token, String memberId, int beans) {
        if (null != model) {
            model.recharge(this, tenantId, token, memberId, beans);
        }
    }

    @Override
    public void getUserData(String tenantId, String token, String memberId) {
        if (null != model) {
            model.getUserData(this, tenantId, token, memberId);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onSuccess(baseBean);
        }
    }

    @Override
    public void onSuccess(UserDataBean userDataBean) {
        if (null != view) {
            view.onSuccess(userDataBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}